import os
import re

Missions = [
    ("/Volumes/ext/projects/22_11_27_Central_虫洞/resources/虫洞动画0215", "虫洞动画0215_00", "holeX_"),
]


def run(options):
    directory = options[0]
    regexp = re.compile(options[1])
    replace = options[2]
    print(directory + ":")

    for parent, dir_names, filenames in os.walk(directory):
        for old_filename in filenames:
            new_filename = old_filename.replace(options[1], options[2])
            # new_filename = regexp.sub(replace, old_filename)
            if new_filename != old_filename:
                src = os.path.join(parent, old_filename)
                dst = os.path.join(parent, new_filename)
                os.system("mv '{}' '{}'".format(src, dst))
                print("'{}' -> '{}'".format(old_filename, new_filename))


def rename_files():
    for mission in Missions:
        run(mission)
